package com.socialuni.center.web.utils;

import com.github.promeg.pinyinhelper.Pinyin;
import com.socialuni.center.web.model.DO.oAuth.ThirdUserDO;
import com.socialuni.center.web.model.DO.user.DevAccountDO;
import com.socialuni.sdk.exception.SocialParamsException;
import com.socialuni.sdk.utils.common.ObjectUtil;

/**
 * @author qinkaiyuan
 * @date 2019-10-24 17:28
 */
public class CosUtil {
    public static String getUserImgUrl(String userId) {
        return "user/" + userId + "/*";
    }

    public static String getUserImgPath() {
        ThirdUserDO thirdUserDO = CenterUserUtil.getMineThirdUser();
        //初步查看没问题，是unionId生成的对应dev和user
        String thirdUserId = thirdUserDO.getThirdUserId();
        DevAccountDO devAccountDO = DevAccountUtils.getDevAccount();
        Long devNum = devAccountDO.getDevNum();
//        添加应用名称
        String shortName = Pinyin.toPinyin(devAccountDO.getAppName(), "").toLowerCase();
        if (ObjectUtil.hasEmpty(devNum, shortName, thirdUserId)) {
            throw new SocialParamsException("包含空内容");
        }
        return devNum + "/" + shortName + "/user/" + thirdUserId + "/";
    }
}
